package com.luoy.java8;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @desc:
 * @author: luoy
 * @date: 2021-01-07 19:04
 */
public class Distinct {


    public static void main(String[] args) {
        ArrayList<ResourceInfo> strings = new ArrayList<>();

        for (int i = 0;i<6;i++){
            ResourceInfo resourceInfo = new ResourceInfo();
            resourceInfo.setRes("222.jar");
            resourceInfo.setId(i);
            strings.add(resourceInfo);
        }
        for (int i = 0;i<6;i++){
            ResourceInfo resourceInfo = new ResourceInfo();
            resourceInfo.setRes("333.jar");
            strings.add(resourceInfo);
        }


        List<ResourceInfo> collect = strings.parallelStream().distinct().collect(Collectors.toList());

        collect.forEach(System.out::println);

        List<String> collect1 = collect.parallelStream().map(x -> x.getRes()).distinct().collect(Collectors.toList());

        String join = String.join(",", collect1);
        System.out.println("--jars "+join);
        collect1.forEach(System.out::println);
    }



}
@Data
class ResourceInfo{
    private  int id;

    private String res;
}